package com.ss.warfarin.common.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;

public class DbUtils {
	
	private static final ResourceBundle rb = ResourceBundle.getBundle("dbconfig");
	
	public static Connection getConnection() throws ClassNotFoundException, SQLException {
		//loading driver
		Class.forName(rb.getString("db.driver"));
		
		//connection to database
		Connection connection = DriverManager.getConnection(rb.getString("db.url"), rb.getString("db.username"), rb.getString("db.password"));
		
		return connection;
	}
	
	public static void closeConnection(Connection connection) throws SQLException {
		connection.close();
	}
	
}
